package com.example.xiaomi.controller;

import com.example.xiaomi.entity.userinfo;
import com.example.xiaomi.entity.topic;

import com.example.xiaomi.service.UserService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@RestController
@RequestMapping("user")
@CrossOrigin
public class UserController {
    @Autowired
    private UserService service;
    @GetMapping("/pages")
    public PageInfo<userinfo> getPagesUser(Integer pageNum, Integer pageSize, String user_name){
        PageInfo<userinfo> pageInfo = service.findUserPages(pageNum,pageSize,user_name);
        return pageInfo;
    }

    /**
     * 根据用户名提取用户信息： http://localhost:8080/user/list   get请求
     * @return
     */
    @GetMapping("list")
    public List<userinfo> findAllUser(){

        return service.findAllUser();
    }


    /**
     * 根据主键编号提取用户信息： http://localhost:8080/get/#{id}    get请求
     * @return
     */
    @GetMapping("/get/{id}")
    public userinfo getUserBYID(@PathVariable("id") Integer mid){
        userinfo info =service.findUserBYID(mid);
        return info;
    }





}
